<template>
  <div>
    <svg :style="{ width, height }">
      <!-- xlink:href执行用哪一个图标，属性值不必为#icon-图标名 -->
      <!-- use标签fill属性可以设置图标的颜色 -->
      <use :xlink:href="prefix + name" :fill="color"></use>
    </svg>
  </div>
</template>

<script setup lang="ts">
/* 接受父组件传递的参数 */
defineProps({
  prefix: {
    type: String,
    default: "#icon-",
  },
  name: {
    type: String,
    default: "",
  },
  /* 接受父组件传递的颜色 */
  color: {
    type: String,
    default: "",
  },
  width: {
    type: String,
    default: "16px",
  },
  height: {
    type: String,
    default: "16px",
  },
});
</script>
<script lang="ts">
import { defineComponent } from "vue";
export default defineComponent({
  name: "SvgIcon",
});
</script>
<style scoped></style>
